$(document).ready(function(){
	$('a.submit').click(function(e){
		e.preventDefault();
		$('form').submit();
	})
	$('#select-box li').click(function(){
		$('.cbo-hidden-id').val($(this).attr('id'));
		if($(this).hasClass('value')){
			$('.cbo-hidden-name').val($('a', this).html());
		}else{
			$('.cbo-hidden-name').val('');
		}
		$('form').submit();
	});
	$('#select-box-district li').click(function(){
		$('.cbo-hidden-district-id').val($(this).attr('id'));
		if($(this).hasClass('value')){
			$('.cbo-hidden-district-name').val($('a', this).html());
		}else{
			$('.cbo-hidden-district-name').val('');
		}
		$('form').submit();
	});
	$('form').on('submit',function(){
			if($('#usersPassword').val() != "undefined"){
			   if($('#usersPassword').val()!=$('#usersRetypePassword').val()){
			       alert('Password not matches');
			       $('#usersPassword').focus();
			       return false;
			   }
			   return true;
			}
	});
	/* get District by Province */
	$('#provinceName').change(function(){
		var base_url = $('#base').val();
		var pro_id = $(this).val();
		if(pro_id == ""){}
		$.ajax({
			type:'post',
			url: base_url + 'depot-management/get-districts/',
			data: 'sb_proId=' + pro_id,
			beforeSend:function(){
				$('#provinceName').parent().after().append('<span class="loading">&nbsp;</span>');
			},
			success:function(data){
				$('#districtName').find('option').remove();
				$('#districtName').append(data);
				$('#provinceName').next().remove();
			}
		});
	});
});